import { Controller, Get, Param, UseGuards } from '@nestjs/common'
import { AdminGuard } from 'src/core/admin.guard'
import { AzureAppRenewService } from 'src/services/azure-app-renew.service'

@Controller('azure-app-renew')
@UseGuards(AdminGuard)
export class AzureAppRenewController {

  constructor(
    private readonly azureAppRenewService: AzureAppRenewService,
  ) { }

  @Get(':clientId/start')
  public start(@Param('clientId') clientId: string) {
    this.azureAppRenewService.start(clientId)
    return true
  }

  @Get(':clientId/stop')
  public stop(@Param('clientId') clientId: string) {
    this.azureAppRenewService.stop(clientId)
    return true
  }

  @Get(':clientId')
  public get(@Param('clientId') clientId: string) {
    return this.azureAppRenewService.getRenewInfo(clientId)
  }
}
